<%@ page contentType="text/html;charset=UTF-8"%>
<%@ page import="java.util.*"%>
<%@ page import="org.json.*"%>
<%@ page import="com.gzgi.framework.*"%>
<%@ page import="com.gzgi.framework.el.*"%>
<%@ page import="com.gzgi.framework.util.*"%>
<%@ page import="com.gzgi.framework.config.*"%>
<%@ page import="com.gzgi.framework.context.*"%>
<%@ page import="com.gzgi.framework.tree.*"%>
<%@ page import="com.gzgi.framework.dataitem.*"%>
<%@ page import="com.gzgi.framework.sys.*"%>
<%@ page import="com.gzgi.framework.sys.model.*"%>
<%@ page import="com.gzgi.framework.resource.*"%>
<%@ page import="com.gzgi.workflow.jbpm.model.*"%>
<%@ page import="com.gzgi.workflow.jbpm.container.*"%>
<%@ page import="com.gzgi.form.service.*"%>
<%@ page import="com.gzgi.form.graph.def.*"%>
<%@ page import="com.gzgi.form.graph.exe.*"%>
<%@ page import="org.apache.commons.lang.*"%>
<%
     String actorId = (String) request.getSession().getAttribute(
				SecurityContext.LOGIN_ACTOR_ID);
	 String app_name = request.getParameter("app_name");
	 String rowId = request.getParameter("rowId"); 	 
 	 if(rowId==null || app_name == null) {
		 return;
	 }
	 FormModel formModel = null;
	 FormService formService = null;
	 ResourceService resourceService = null;
	 FormDefinition formDefinition = null;
	 FormApplication formApplication = null;
	 Collection dataFiles =  null; 
     try{
		 formService = (FormService) ContextFactory.getBean("formService");
		 resourceService = (ResourceService) ContextFactory
				.getBean("resourceService");
		 FormContext formContext = new FormContext();
		 formApplication = formService.getFormApplicationByName(formContext, app_name);
         if(formApplication != null && StringUtils.isNotEmpty(formApplication.getFormName())){
			 formDefinition = formService.getLatestFormDefinition(formContext, formApplication.getFormName());
			 formContext.setFormDefinition(formDefinition);
             formModel = formService.getFormModel(formContext, rowId);
			 if(formModel != null && StringUtils.isNotEmpty(formModel.getResourceId())){
                     Resource resource = resourceService.getResourceWithDataFiles(formModel.getResourceId());
					 if(resource != null){
                             dataFiles = resource.getDataFiles();
					 }
			 }
		 }
		 }catch(Exception ex){
		  ex.printStackTrace();
	  }

    if(dataFiles != null && dataFiles.size() > 0){
        Iterator iter = dataFiles.iterator();
	    while(iter.hasNext()){
			DataFile dataFile = (DataFile) iter.next();
			if(StringUtils.equals(dataFile.getType(), "DOC")){	
%>
<p align="left">
	<label style="cursor: pointer;" onclick="javascript:loadContentPanel('ocxeditor.jsp');">
		<img src="<%=request.getContextPath()%>/pages/images/m.gif">请假申请1.doc
	</label>
</p>
<%  
	      } 
	    }
	}
%>